<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/templates/template.xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:nu="http://nu.jcperera.homeip.net/facelets" xmlns:p="http://primefaces.org/ui">

	<ui:param name="title" value="NU Application Edit Web Info Site Page" />
	<f:metadata>
		<f:viewParam name="entityid" value="#{webInfoSiteBean.entityid}" />
		<f:viewParam name="entityid" value="#{webInfoPatternBean.parentid}" />
		<f:viewParam name="entityid" value="#{scanProfileBean.parentid}" />
	</f:metadata>

	<ui:define name="body">
		<p:outputPanel style="margin-bottom:10px;">
			<p:messages id="edit-messages" autoUpdate="true" closable="true" showDetail="true" redisplay="no" />

			<p:panel id="edit-panel" header="Edit Web Info Site" style="margin-bottom:10px;">
				<h:panelGrid columns="3" style="margin-bottom:10px;">
					<h:outputLabel for="entityid" value="ID: " />
					<p:inputText id="entityid" value="#{webInfoSiteBean.entityid}" required="false" label="ID" size="45"
						readonly="true" disabled="true" />
					<p:message for="entityid" />

					<h:outputLabel for="url" value="URL: *" />
					<p:inputText id="url" value="#{webInfoSiteBean.url}" required="true" label="URL" size="150">
						<f:validateLength minimum="15" />
					</p:inputText>
					<p:message for="url" />

					<h:outputLabel for="parameters" value="Parameters: *" />
					<p:inputText id="parameters" value="#{webInfoSiteBean.parameters}" required="true" label="Parameters" size="100">
						<f:validateLength minimum="10" />
					</p:inputText>
					<p:message for="parameters" />
				</h:panelGrid>

				<p:commandButton value="Save" actionListener="#{webInfoSiteBean.saveWebInfoSite}" id="saveButton"
					icon="ui-icon-disk" update="edit-panel,edit-messages"></p:commandButton>

				<p:commandButton value="Delete" id="deleteButton" onclick="confirmation.show()" icon="ui-icon-trash" type="button">
				</p:commandButton>

				<p:button value="Go to list" outcome="/pages/webinfosite/list.xhtml?faces-redirect=true" process="@this" />

				<p:confirmDialog header="Confirmation"
					widgetVar="confirmation" severity="alert" closeOnEscape="true" appendToBody="true">
					<f:facet name="message">
						<h:outputText value="Are you sure you want to delete the entity?" />
						<br/>
						<h:outputText value="This will recursively delete ALL children entities" />
					</f:facet>
					<p:commandButton value="Yes" icon="ui-icon-check" action="#{webInfoSiteBean.deleteWebInfoSite}" />
					<p:commandButton value="No" icon="ui-icon-close" onclick="confirmation.hide()" type="button" />
				</p:confirmDialog>
			</p:panel>
		</p:outputPanel>

		<p:panel id="list-panel-1" header="List of Web Info Patterns for the Web Info Site" style="margin-bottom:10px;">
			<p:dataTable id="webInfoPatternTable" var="webInfoPattern" value="#{webInfoPatternBean.webInfoPatterns}"
				widgetVar="webInfoPatternsTable" emptyMessage="No Web Info Patterns found for the current Web Info Site"
				rowKey="#{webInfoPattern.entityid}" paginator="true" rows="15"
				selection="#{webInfoPatternBean.selectedWebInfoPattern}" selectionMode="single">

				<p:ajax event="rowSelect" listener="#{webInfoPatternBean.onRowSelect}" />

				<p:column id="idColumn" headerText="Id" width="5%">
					<h:outputText value="#{webInfoPattern.entityid}" />
				</p:column>

				<p:column id="xslPatternColumn" headerText="XSL pattern" width="25%">
					<h:outputText value="#{webInfoPattern.xslPattern}" />
				</p:column>

				<p:column id="formatColumn" headerText="Format" width="20%">
					<h:outputText value="#{webInfoPattern.format}" />
				</p:column>

				<p:column id="fieldNameColumn" headerText="Field Name" width="10%">
					<h:outputText value="#{webInfoPattern.fieldName}" />
				</p:column>

				<p:column id="isPrimaryColumn" headerText="is Primary?" width="5%">
					<h:outputText value="#{webInfoPattern.isPrimary}" />
				</p:column>

				<p:column id="createdByColumn" headerText="Created By" width="10%">
					<h:outputText value="#{webInfoPattern.createdBy}" />
				</p:column>

				<p:column id="createdWhenColumn" headerText="Created When" width="10%">
					<h:outputText value="#{webInfoPattern.createdWhenAsDate}">
						<f:convertDateTime dateStyle="short" timeZone="EST" type="both" />
					</h:outputText>
				</p:column>

				<p:column id="modifiedByColumn" headerText="Modified By" width="10%">
					<h:outputText value="#{webInfoPattern.modifiedBy}" />
				</p:column>

				<p:column id="modifiedWhenColumn" headerText="Modified When" width="10%">
					<h:outputText value="#{webInfoPattern.modifiedWhenAsDate}">
						<f:convertDateTime dateStyle="short" timeZone="EST" type="both" />
					</h:outputText>
				</p:column>

				<p:column id="localVersionColumn" headerText="Local" width="5%">
					<h:outputText value="#{webInfoPattern.localVersion}" />
				</p:column>

				<p:column id="globalVersionColumn" headerText="Global" width="5%">
					<h:outputText value="#{webInfoPattern.globalVersion}" />
				</p:column>
			</p:dataTable>

			<br style="font-size: 8px;" />

			<p:button value="Create New" outcome="/pages/webinfopattern/new.xhtml?faces-redirect=true" process="@this">
				<f:param name="parentid" value="#{webInfoPatternBean.parentid}" />
			</p:button>
		</p:panel>

		<p:panel id="list-panel-2" header="List of Scan Profiles for the Web Info Site" style="margin-bottom:10px;">
			<p:messages autoUpdate="true" closable="false" showDetail="true" redisplay="no" />

			<p:dataTable id="scanProfileTable" var="scanProfile" value="#{scanProfileBean.scanProfiles}"
				widgetVar="scanProfilesTable" emptyMessage="No Scan Profiles found with given criteria"
				rowKey="#{scanProfile.entityid}" paginator="true" rows="15" selection="#{scanProfileBean.selectedScanProfile}"
				selectionMode="single" style="margin-bottom:10px;">

				<p:ajax event="rowSelect" listener="#{scanProfileBean.onRowSelect}" />

				<p:column id="idColumn" headerText="Id" width="5%">
					<h:outputText value="#{scanProfile.entityid}" />
				</p:column>

				<p:column id="nameColumn" headerText="Name" width="15%">
					<h:outputText value="#{scanProfile.name}" />
				</p:column>

				<p:column id="periodicityColumn" headerText="Periodicity" width="5%">
					<h:outputText value="#{scanProfile.periodicity} #{scanProfile.periodicityUnit}"></h:outputText>
				</p:column>				

				<p:column id="howManyUpColumn" headerText="How many up" width="5%">
					<h:outputText value="#{scanProfile.howManyUp}"></h:outputText>
				</p:column>	
				
				<p:column id="howManyDownColumn" headerText="How many down" width="5%">
					<h:outputText value="#{scanProfile.howManyDown}"></h:outputText>
				</p:column>	

				<p:column id="isRunningColumn" headerText="Is Running?" width="5%">
					<h:outputText value="#{scanProfile.isRunning}"></h:outputText>
				</p:column>

				<p:column id="lastRunStartedColumn" headerText="Last Run Start" width="10%">
					<h:outputText value="#{scanProfile.lastRunStarted}"></h:outputText>
				</p:column>

				<p:column id="lastRunStoppedColumn" headerText="Last Run Stop" width="10%">
					<h:outputText value="#{scanProfile.lastRunStopped}"></h:outputText>
				</p:column>

				<p:column id="createdByColumn" headerText="Created By" width="10%">
					<h:outputText value="#{scanProfile.createdBy}" />
				</p:column>

				<p:column id="createdWhenColumn" headerText="Created When" width="10%">
					<h:outputText value="#{scanProfile.createdWhenAsDate}">
						<f:convertDateTime dateStyle="short" timeZone="EST" type="both" />
					</h:outputText>
				</p:column>

				<p:column id="modifiedByColumn" headerText="Modified By" width="10%">
					<h:outputText value="#{scanProfile.modifiedBy}" />
				</p:column>

				<p:column id="modifiedWhenColumn" headerText="Modified When" width="10%">
					<h:outputText value="#{scanProfile.modifiedWhenAsDate}">
						<f:convertDateTime dateStyle="short" timeZone="EST" type="both" />
					</h:outputText>
				</p:column>

				<p:column id="localVersionColumn" headerText="Local" width="5%">
					<h:outputText value="#{scanProfile.localVersion}" />
				</p:column>

				<p:column id="globalVersionColumn" headerText="Global" width="5%">
					<h:outputText value="#{scanProfile.globalVersion}" />
				</p:column>
			</p:dataTable>
			
			<p:button value="Create New" outcome="/pages/scanprofile/new.xhtml?faces-redirect=true" process="@this">
				<f:param name="parentid" value="#{scanProfileBean.parentid}" />
			</p:button>
		</p:panel>

	</ui:define>
</ui:composition>